<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../css/app.css">
    <link rel="stylesheet" type="text/css" href="../css/index.css">
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="/h5/js/all.js"></script>
</head>
<body>
<!--
    制作者：九哥
    页面：工人详情页面
    时间：2019-03-01
-->





<!----------工人详情页面---------->
<div id="staffShowPage"><!--此ID页面切换用-->
    <div id="staffShowTitle">
        <b>简历详情</b>
        <img src="../images/return.png" id="staffShowRtn">
    </div>
    <div id="staffShowIntro">
        <table>
            <tr>
                <td><b id="name"></b></td>
                <td rowspan="2" style="text-align:right">
                    <img id="image" src="../images/toux01.png" width="50">
                </td>
            </tr>
            <tr>
                <td><p id="sex">男·28岁·15190783028</p></td>
            </tr>
        </table>
    </div>
    <div style="height:15px;"></div>
    <div id="staffShowDetail">
        <p><b>基本信息</b></p>
        <table>
            <tr>
                <td class="left">最高学历</td>
                <td id="education" class="right"></td>
            </tr>
            <tr>
                <td class="left">体重</td>
                <td id="weight" class="right"></td>
            </tr>
            <tr>
                <td class="left">政治面貌</td>
                <td id="political_status" class="right"></td>
            </tr>
            <tr>
                <td class="left">籍贯</td>
                <td id="native_place" class="right"></td>
            </tr>
            <tr>
                <td class="left">民族</td>
                <td id="nationality" class="right"></td>
            </tr>
            <tr>
                <td class="left">婚姻</td>
                <td id="marriage" class="right"></td>
            </tr>
            <tr>
                <td class="left">住宿情况</td>
                <td id="house" class="right"></td>
            </tr>
            <tr>
                <td class="left">身份证号码</td>
                <td id="idcard" class="right"></td>
            </tr>
            <tr>
                <td class="left">户口地址</td>
                <td id="household_address" class="right">
            </tr>
            <tr>
                <td class="left">紧急联系人</td>
                <td id="contact_person" class="right"></td>
            </tr>
            <tr>
                <td class="left">期望薪资</td>
                <td class="right">8000元</td>
            </tr>
            <tr>
                <td class="left">专业技能</td>
                <td id="skill" class="right"></td>
            </tr>
            <tr>
                <td class="left">特长爱好</td>
                <td id="hobby" class="right"></td>
            </tr>
        </table>
        <p onclick="getMore()">
            <b style="color:#0088cc;">更多信息</b>
        </p>
        <br><hr><br>
        <span id="more" style="display:none;">
            <!--更多信息-->
            <div style="height:10px;background:#f4f4f4;"></div>
            <p><b>教育背景</b></p>
            <table id="edu_bgs">
                <tr>
                    <td class="left">毕业院校</td>
                    <td class="right">浙江财经大学</td>
                </tr>
                <tr>
                    <td class="left">起止时间</td>
                    <td class="right">2007.9--2011.6</td>
                </tr>
                <tr>
                    <td class="left">专业</td>
                    <td class="right">计算机</td>
                </tr>
                <tr>
                    <td class="left">所获奖项</td>
                    <td class="right"></td>
                </tr>
                <tr>
                    <td class="left">民族</td>
                    <td class="right"></td>
                </tr>
            </table>
            <div style="height:10px;background:#f4f4f4;"></div>
            <p><b>家庭成员</b></p>
            <table id=“familys>
                <tr>
                    <td class="left">姓名</td>
                    <td class="right">李某某</td>
                </tr>
                <tr>
                    <td class="left">称谓</td>
                    <td class="right">父亲</td>
                </tr>
                <tr>
                    <td class="left">工作单位</td>
                    <td class="right">某某公司</td>
                </tr>
                <tr>
                    <td class="left">联系电话</td>
                    <td class="right">1505050550</td>
                </tr>
            </table>
            <div style="height:10px;background:#f4f4f4;"></div>
            <p><b>自我评价</b></p>
            <table>
                <tr>
                    <td class="left">自我评价</td>
                    <td class="right"></td>
                </tr>
                <tr>
                    <td class="left">擅长技能</td>
                    <td class="right"></td>
                </tr>
                <tr>
                    <td class="left">特长爱好</td>
                    <td class="right"></td>
                </tr>
            </table>
            <div style="height:10px;background:#f4f4f4;"></div>
            <p><b>业务类型</b></p>
            <table>
                <tr>
                    <td class="left">业务类型</td>
                    <td class="right">长期工</td>
                </tr>
                <tr>
                    <td class="left">技术等级</td>
                    <td class="right">中级</td>
                </tr>
                <tr>
                    <td class="left">工作经历</td>
                    <td class="right">
                        多多理财是浙江多多互联网金融信息服务有限公司旗下 一家互联网金融信息服务平台,为用户提供汽车质押、供 应链金融等低风险高收益的
                    </td>
                </tr>
            </table>
        </span>
        <!--企业操作按钮-->
        <!--1工人投递中，2企业拒绝投递，3企业面试邀请，4工人拒绝邀请，5面试中，-->
        <!--6面试失败，7面试成功，8工人评价，9企业评价，10完成-->
        <p class="submit">
            招聘岗位：
            <select id="job">
                <option value="">选择</option>
            </select>
            <br><br>
            <button class="call">去交流</button>
            &nbsp; &nbsp;
            <span id="apply"></span>
        </p>
        <br><br><br>
    </div>
</div>
<!----------工人详情页面---------->





<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->
</body>
<script type="text/javascript" src="../js/indexPageChange.js"></script>
<script type="text/javascript" src="../js/app.js"></script>
<script type="text/javascript" src="../js/index.js"></script>
<script>
    (function(){
        getIndexList();
        getJobsByCid();
        getMeet();
    })();
    /**
     * 获取信息
     * */
    function getIndexList(){
        var uid = JSON.parse(getQueryString('ids')).uid;
        $('.call').attr('call',uid);
        $.ajax({
            url: getDomain()+'/api/home/staff/detail',
            type: 'get',
            data: {
                id: uid
            },
            success: function(data) {
//                console.log(data); return
                if (data.code === 200) {
                    var data = data.data;
                    $('#name').html(data.name);
                    $('#image').attr('src', data.image);
                    $('#sex').html(`${data.sex === 1 ? '男':'女'} ${data.age}岁 ${data.phone}`);
                    $('#education').html(`${data.education === 1 ? '小学' : data.education === 2 ? '初中': data.education === 3 ? '高中/中专/专科' : data.education === 4 ? '本科' : data.education === 5 ? '研究生': data.education === 6 ? '博士': '其他'}`);
                    $('#weight').html(`${data.weight}kg`)
                    $('#political_status').html(`${data.political_status === 1 ? '群众' : data.political_status === 2 ? '团员' : '党员'}`)
                    $('#native_place').html(data.native_place);
                    $('#nationality').html(data.nationality);
                    $('#marriage').html(data.marriage);
                    $('#house').html(data.house);
                    $('#idcard').html(data.idcard);
                    $('#household_address').html(data.household_address);
                    $('#contact_person').html(data.contact_person);
                    $('#skill').html(data.skill);
                    $('#hobby').html(data.hobby);
                }
            }
        });
    }
    function getQueryString(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return unescape(r[2]);
        }
        return null;
    }
    //获取更多信息
    function getMore(){
        var userInfo = cacheGet('userInfo');
        if (userInfo.type<2) {
            getAppErrMsg('权限不足！','',0); return
        }
        $('#more').toggle();
    }
    //招聘岗位，通过企业UID
    function getJobsByCid(){
        var userInfo = cacheGet('userInfo');
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            cid:0, //type==2,cid==uid
            type:2 //1工人，2企业
        };
        $.ajax({
            type:'post',
            url:getDomain()+'/api/home/recruit/jobsbycid',
            data:formData,
            success: function (res) {
                //console.log(res); return
                var  h = '';
                if (res.code!=0) {
                    console.log(res);
                    $('#job').html('<option>没有岗位</option>');
                    getAppErrMsg(res.msg,'',0);
                    return
                }
                var resData = res.data;
//                console.log(resData[0]);
                for (var i=0;i<resData.length;i++) {
                    h += '<option value="'+resData[i].id+'" ';
                    h += ' >';
                    h += resData[i].jobName;
                    h += '</option>';
                }
                $('#job').html(h);
            }
        });
    }
    //去交流
    function getTalk(){
        var uid = JSON.parse(getQueryString('ids')).uid;
        var userInfo = cacheGet('userInfo');
        var jobId = $('#job').val();
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            talkType:2, //企业发起会话
            uid2:uid,
            job:jobId
        };
//        console.log(formData); return
        $.ajax({
            type:'post',
            url:'/api/msg/add',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code!=0) {
                    getAppErrMsg(res.msg,'',2);
                    console.log(res);
                    return
                }
                var resData = res.data;
                console.log(resData);
                var talkId = resData.talkId;
                var own = resData.own;
                var other = resData.other;
                var otherName = resData.otherName;
                var jobId = resData.jobId;
                var prefix = '?id='+talkId+'&own='+own+'&other='+other+'&otherName='+otherName+'&jobId='+jobId;
                window.location.href = '/h5/message/jobWin.html'+prefix;
            }
        });
    }
    //获取邀请
    function getMeet(){
        var uid = JSON.parse(getQueryString('ids')).uid;
        var userInfo = cacheGet('userInfo');
        var jobId = $('#job').val();
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            genre:2, //企业发起会话
            uid2:uid,
            job:jobId
        };
        $.ajax({
            type:'post',
            url:'/api/home/recruit/meet-get',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code==-44) {
                    $('#apply').html('<button class="grey">已邀请过</button>');
                    console.log(res);
                    return
                } else if (res.code!=0) {
                    getAppErrMsg(res.msg,'',0);
                    $('#apply').html('<button class="grey">未邀请</button>');
                    return
                } else {
                    $('#apply').html('<button onclick="setMeet()">邀请面试</button>');
                }
            }
        });
    }
    //设置邀请
    function setMeet(){
        var uid = JSON.parse(getQueryString('ids')).uid;
        var userInfo = cacheGet('userInfo');
        var jobId = $('#job').val();
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            genre:2, //企业发起会话
            uid2:uid
        };
        $.ajax({
            type:'post',
            url:'/api/home/recruit/meet-get',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code-=0) {
                    getAppErrMsg(res.msg,'',0);
                    $('#apply').html('<button class="grey">未邀请</button>');
                    return
                }
                $('#apply').html('<button class="grey">邀请中</button>');
                setTimeout(function(){
                    window.location.href = '/h5/my/job/staffJob.html';
                },1000*2);
            },
            error:function(){
                console.log('操作失败！');
            }
        });
    }
    //获取域名
    function getDomain(){
//        return 'http://test1.fuzhuangchangongxiao.cn';
        return '';
    }
</script>
</html>